<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015/6/25
 * Time: 19:19
 */

namespace Admin\Controller;

// 了解发修
class AboutController extends AdminController
{
    // 了解/文化
    function index()
    {
        $where['type'] = I('type');
        if (IS_POST) {
            $data['content'] = I('post.content');
            $data['pic'] = implode(',', I('post.pic'));
            if (M('about')->where($where)->save($data) !== false) {
                $this->success('保存成功',U('index',array('type'=>I('type'))));
            } else {
                $this->error('保存失败');
            }
        } else {
            if ($info = M('about')->where($where)->find()) {
                $info['pic'] = explode(',', $info['pic']);
            } else {
                M('about')->add($where);
            }
            $this->assign('info', $info);
            switch($where['type']){
                case 'introduce':
                    $this->assign('meta_title','介绍');
                    break;
                case 'culture':
                    $this->assign('meta_title','文化');
            }
            $this->display();
        }
    }
}